<?php

namespace app\admin\model\classroom;

use think\Model;


class Banner extends Model
{





    // 表名
    protected $name = 'classroom_banner';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [];


    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $url = empty($row['url']) ? '#' : $row['url'];
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk], 'url' => $url]);
        });
    }

    public function getTypeList()
    {
        return ['0' => __('学习'), '1' => __('活动'), '2' => __('首页'), '3' => __('党会'), '5' => __('我的')];
    }
}
